﻿using Microsoft.AspNetCore.Mvc;
using Testudo.Core;
using Testudo.Services;
using Testudo.ViewModels;

namespace Testudo.WebApp.Controllers;

[ApiController]
[Route("api/[controller]/[action]")]
public class ScenarioController : ControllerBase
{
    public ScenarioController(IScenarioService service)
    {
        Service = service;
    }

    private IScenarioService Service { get; }

    [HttpGet]
    public async Task<ActionResult<List<ScenarioConfigVM>>> GetList()
    {
        return this.FineResult(await Service.GetList());
    }


    [HttpGet]
    public async Task<ActionResult<ScenarioConfigVM>> Get(Guid id)
    {
        return this.FineResult(await Service.Get(id));
    }

    [HttpPost]
    public async Task<ActionResult<ScenarioConfigVM>> Create([FromBody] CreateScenarioConfigVM vm)
    {
        return this.FineResult(await Service.Create(vm));
    }

    [HttpPut]
    public async Task<ActionResult<ScenarioConfigVM>> Update([FromBody] UpdateScenarioConfigVM vm)
    {
        return this.FineResult(await Service.Update(vm));
    }

    [HttpPatch]
    public async Task<ActionResult<ScenarioConfigVM>> Patch([FromBody] PatchData vm)
    {
        return this.FineResult(await Service.Patch(vm));
    }

    [HttpDelete]
    public async Task<ActionResult<bool>> Delete([FromBody] DeleteScenarioConfigVM vm)
    {
        var result = await Service.Delete(vm);
        return this.FineResult(result);
    }
}